<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    请选择您想要的颜色：<br>
    <label for="red"></label>
    <input type="checkbox" name="color" value="red" id="red"> 红色

    <label for="purple"></label>
    <input type="checkbox" name="color" value="purple" id="purple"> 紫色

    <label for="blue"></label>
    <input type="checkbox" name="color" value="blue" id="blue"> 蓝色

</body>
</html>
<script>
    let radios = document.querySelectorAll("input[type='checkbox']");
    radios.forEach(radio => {
        radio.addEventListener('click',() => {
            if (radio.checked) {
                console.log('选中的颜色是：' + radio.value)
            }
        })
    })

</script>